package cn.ymjr.sys.config;

import cn.ymjr.sys.util.DictInit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * Created by tiny on 2018/9/14.
 */
@Component("BeanDefineConfig")
public class BeanDefineConfig implements ApplicationListener<ContextRefreshedEvent> {
    private static final Logger logger = LoggerFactory.getLogger(BeanDefineConfig.class);

    @Autowired
    private DictInit dictInit;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        logger.info("START:spring初始化开始======================>");
        if (contextRefreshedEvent.getApplicationContext().getParent() == null) {//root application context 没有parent，他就是老大.
            logger.info("启动projectInit的start方法进行参数的初始化======================>");
            dictInit.start();
        } else {
            dictInit.start();
            logger.info("spring初始化时,执行!= null======================>");
        }
        logger.info("END:spring初始化完毕======================>");
    }
}
